package com.jgj.zxkj.lookandcheckjggroupinfo;

import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.blankj.utilcode.util.LogUtils;
import com.sa.all_cui.mix_core.delegate.DoggerDelegate;

import butterknife.BindView;

/**
 * Created by all-cui on 2017/10/26.
 */

public class TestDelegate extends DoggerDelegate {
    @BindView(R.id.iv)
    ImageView iv;

    /*@Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = View.inflate(_mActivity,R.layout.delegate_test,null);
        ButterKnife.bind(this,view);
        printImageWidthAndHeight();
        return view;
    }*/
    @Override
    public Object setLayout() {
        return R.layout.delegate_test;
    }

    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, View view) {
        printImageWidthAndHeight();
    }

    public void printImageWidthAndHeight(){
        Drawable drawable = iv.getDrawable();
        if (drawable!=null){
            BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
            Bitmap bitmap = bitmapDrawable.getBitmap();
            LogUtils.i("width:"+bitmap.getWidth()+"\r\n"+
            "height:"+bitmap.getHeight());
        }else{
            LogUtils.i("drawable is null");
        }
    }
}
